<!-- application/views/scripts/blog/view.phtml -->
<?php echo $this->render('/blog/edit.phtml'); ?>

<script language="javascript">
function editBlog(bid) {
	showAddBlog(1);	
	setValueForBlogForm(bid,$("span#blog-title_" + bid).text(),
			$("div#blog-body_" + bid).html(),
			$("span#blog-tag_" + bid).text(),
			$("span#blog-category_" + bid).text(),
			$("span#blog-privilege_" + bid).text());
}
</script>
<?php $blog = $this->blog;
	echo "<div class='blog-entry'>";
	echo "<div class='blog-title ' > <span id='blog-title_".$blog->getBid()."'>".$blog->getTitle()."</span></div>";
	echo "<div class='blog-date'>Created: ".$blog->getCreateDate()."&nbsp;&nbsp;Updated: ".$blog->getUpdateDate()."</div>";
	if (isset($_SESSION['userinfo'])) {
		echo "<div class='blog-operation'><a href='#' onclick='editBlog(".$blog->getBid().")'>edit</a>&nbsp;|&nbsp;"
		."<a href='/blog/delete?blogId=".$blog->getBid()."'>delete</a>&nbsp;|&nbsp;";
		echo "权限: <span id='blog-privilege_".$blog->getBid()."'>";
		if(Application_Model_Constants::PRIVILEGE_TYPE_PUBLIC == $blog->getPrivilegeType()) {
			echo Application_Model_Constants::PRIVILEGE_TYPE_PUBLIC_STR;
		} else {
			echo Application_Model_Constants::PRIVILEGE_TYPE_PRIVATE_STR;
		}
		echo "</span></div>";
	}
	echo "<p><div class='blog-content' id='blog-body_".$blog->getBid()."'>".$blog->getContent()."</div></p>";
	echo "<div class='blog-footer'> Category:&nbsp;<span class='blog-category' id='blog-category_".$blog->getBid()."'>".
		"<a href='#' onclick='showCategory(".$blog->getCategoryId().")'>".$blog->getCategory()."</a>".
		"</span>&nbsp;&nbsp;";
	echo "Tags:&nbsp;<span class='blog-tag' id='blog-tag_".$blog->getBid()."'>";
	foreach ($blog->getTags() as $tag) {
	 echo "<a href='#' onclick='showTag(".$tag['tid'].")'>".$tag['tag']."</a>"."&nbsp;";
	}
	echo "</span>";//blog-tag
	echo "</div>";
	echo "</div>";//blog-entry
?>

<?php 
if (isset($_SESSION['userinfo'])) {
	echo $this->render('/comment/add.phtml');
?>

<!--Comments list-->
<script type="text/javascript">
$().ready(function() {
	setHiddenValue('<?php echo Application_Model_Constants::CONTENT_TYPE_BLOG ?>','<?php echo $blog->getBid(); ?>','<?php echo $_SESSION['userinfo']['uid'] ?>');
});
</script>
<?php 
}	
?>
<?php echo $this->render('/comment/list.phtml');?>
